home *** CD-ROM | disk | FTP | other *** search
- #include <pragmas/rtracker_pragmas.h>
- #include <exec/libraries.h>
- #include <exec/memory.h>
- #include <clib/rtracker_protos.h>
-
- #include "main.h"
- #include "nodes.h"
-
- extern struct Library * RTrackerBase ;
-
- extern SPoint * ipoint,*current ;
-
- void AddPoint(struct Window * win, ULONG x, ULONG y) {
- /* add this point to the list relative to arrow centre (100,150)
- */
- SPoint * np ;
-
-
- np = NewAllocVec(sizeof(SPoint), MEMF_PUBLIC|MEMF_CLEAR) ;
- /* transform window x to normal x
- * idem with y
- */
- if (np) {
- /* when something goes wrong (memory shortage) then do nothing
- */
- x = x - win->BorderLeft + (GRID / 2) ;
- y = y - win->BorderTop + (GRID / 2) ;
- x = x / GRID ;
- y = y / GRID ;
- x = x * GRID ;
- y = y * GRID ;
- np->x = x - PX ;
- np->y = y - PY ;
-
- /*insert the point after the current one
- */
- np->next = current->next ;
- current->next = np ;
- /* make this new point, the current point
- */
- current = np ;
- }
-
-
- }
-
- BOOL RemPoint(struct Window * win, ULONG x, ULONG y) {
- /* Delete a point from the list
- */
- BOOL deleted = FALSE ;
- SPoint * pp, // previous point
- * dp ; // point to delete
-
- x = x - win->BorderLeft + (GRID / 2) ;
- y = y - win->BorderTop + (GRID / 2) ;
- x = x / GRID ;
- y = y / GRID ;
- x = x * GRID - PX ;
- y = y * GRID - PY ;
-
- pp = ipoint ;
- dp = ipoint->next ;
- while(dp) {
- /* find the point
- */
- if((dp->x == x) && (dp->y == y)) {
- /* point found
- */
- current = pp ; /* change the current point to the previous point */
- DeletePoint(pp) ; /* nb: delete pp->next not pp */
- deleted = TRUE ;
- }else {
- /* go to next
- */
- pp = dp ;
- dp = pp->next ;
- }
- }
-
- return(deleted) ;
- }
-
- void SetCurPoint(struct Window * win, ULONG x, ULONG y) {
- /* set the selected point the current one
- */
- SPoint * dp ; // point to be active
-
- x = x - win->BorderLeft + (GRID / 2) ;
- y = y - win->BorderTop + (GRID / 2) ;
- x = x / GRID ;
- y = y / GRID ;
- x = x * GRID - 104 ;
- y = y * GRID - 144 ;
-
- dp = ipoint->next ;
- while(dp) {
- /* find the point
- */
- if((dp->x == x) && (dp->y == y)) {
- /* point found
- */
- current = dp ;
- }
- dp = dp->next ;
- }
- }
- void ClearPoints(void) {
- /* clear all the points
- */
- SPoint * sp ;
- sp = ipoint ;
- while(sp->next) {
- DeletePoint(ipoint) ;
- }
- current = ipoint ;
- }
-
- void DeletePoint(SPoint * previous) {
- /* delete a single point
- */
- SPoint * del ;
-
- del = previous->next ;
- previous->next = del->next ;
- NewFreeVec(del) ;
-
- }
-